package com.atguigu.java2;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

class NumberThread implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i <= 100; i++) {
            if (i%2 == 0) {
                System.out.println(Thread.currentThread().getName()+":"+i);

            }
        }
    }
}
class NumberThread1 implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i <= 100; i++) {
            if (i%2 != 0) {
                System.out.println(Thread.currentThread().getName()+":"+i);

            }
        }
    }
}
public class ThreadPool {
    public static void main(String[] args) {
        ExecutorService service = Executors.newFixedThreadPool(10);
        ThreadPoolExecutor service1 = (ThreadPoolExecutor)service;
        System.out.println(service.getClass());
        service1.setCorePoolSize(15);
        service.execute(new NumberThread());
        service.execute(new NumberThread1());
        service.shutdown();

//        service1.setKeepAliveTime();

    }
}
